package com.sumer.thread;

/**
 * 线程优先级,优先级高只是先执行概率大
 */
public class ThreadPriority implements Runnable{
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getPriority() + "-->");
    }

    public static void main(String[] args) {
        System.out.println(Thread.currentThread().getPriority());
        ThreadPriority threadPriority = new ThreadPriority();
        Thread thread1 = new Thread(threadPriority);
        Thread thread2 = new Thread(threadPriority);
        Thread thread3 = new Thread(threadPriority);
        Thread thread4 = new Thread(threadPriority);
        thread1.setPriority(1);
        thread1.start();
        thread2.setPriority(10);
        thread2.start();
        thread3.setPriority(6);
        thread3.start();
        thread4.setPriority(2);
        thread4.start();
    }
}
